<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-lx-calendar"></i>投资管理</el-breadcrumb-item>
				<el-breadcrumb-item><i class="el-icon-lx-calendar"></i>投资回报率</el-breadcrumb-item>
                <el-breadcrumb-item>{{category[commodity_category]}}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>

		<div class="container">
            <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
                <el-tab-pane label="影视合约" name="1"></el-tab-pane>
                <el-tab-pane label="破产清算合约" name="2"></el-tab-pane>
                <el-tab-pane label="智能狗合约" name="3"></el-tab-pane>
                <el-tab-pane label="光量子科技合约" name="4"></el-tab-pane>
                <el-tab-pane label="5G合约" name="5"></el-tab-pane>
                <el-tab-pane label="代充值合约" name="6"></el-tab-pane>
            </el-tabs>
			<el-row>
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
					<el-form ref="form" :model="form" label-width="100px">
						<el-form-item label="100USDT">
							<el-input v-model="form.val100" placeholder=""></el-input>
						</el-form-item>
						<el-form-item label="200USDT">
							<el-input v-model="form.val200" placeholder=""></el-input>
						</el-form-item>
                        <el-form-item label="500USDT">
                        	<el-input v-model="form.val500" placeholder=""></el-input>
                        </el-form-item>
                        <el-form-item label="1000USDT">
                        	<el-input v-model="form.val1000" placeholder=""></el-input>
                        </el-form-item>
                        <el-form-item label="5000USDT">
                        	<el-input v-model="form.val5000" placeholder=""></el-input>
                        </el-form-item>
						<!-- <el-form-item label="登录密码">
							<el-input v-model="form.loginpwd" placeholder="必填" ></el-input>
						</el-form-item> -->
                        </el-table-column>
                        <el-form-item label="">
                            <el-button :loading="ifload" type="primary" @click="saveData">保存</el-button>
                        </el-form-item>
					</el-form>
				</el-col>
			</el-row>
		</div>

		<loading :ifload="ifload"></loading>
	</div>
</template>

<script type="text/javascript">
	import loading from '@/components/utils/loading';
	export default{
		components:{loading},
		data() {
			return {
				ifload:false,
                activeName:'1',
                commodity_category:'1',
                commodity_data:[],
                category:{
                    '1':'影视合约',
                    '2':'破产清算合约',
                    '3':'智能狗合约',
                    '4':'光量子科技合约',
                    '5':'5G合约',
                    '6':'代充值合约'
                },
				form:{
                    val100: '',
                    val200: '',
                    val500:'',
                    loginpwd: '',
                    val1000: '',
                    val5000:'',
                    commodity_category:'1'
                },
                search:{
                	commodity_category:''
                },
			}
		},
		created() {
            this.commodity_category = ''+this.$route.query.cid;
            if(this.$route.query.cid) {
                this.activeName = this.$route.query.cid;
            }else{
                this.activeName = 1;
            }
			this.$nextTick(()=>{
				this.getData();
			})
		},
		methods: {
			getData() {
                this.ifload = true;
                this.search.commodity_category = this.commodity_category;
                let param = {search:JSON.stringify(this.search)};
                this.$post_('trade/commodity/list-info',param,(res) => {
                    console.log(res);
                    if(res.code=='0'){
                        this.commodityData = res.data
                        for(var i=0 ; i<res.data.length; i++){
                            switch(parseInt(res.data[i].money_up)){
                                case 100:
                                    this.form.val100 = res.data[i].day_income
                                    break;
                                case 200:
                                    this.form.val200 = res.data[i].day_income
                                    break;
                                case 500:
                                    this.form.val500 = res.data[i].day_income
                                    break;
                                case 1000:
                                    this.form.val1000 = res.data[i].day_income
                                    break;
                                case 5000:
                                    this.form.val5000 = res.data[i].day_income
                                    break;
                                default:
                                    break;
                            }
                        }
                        console.log(res.data);
                        console.log(this.form);
                    }
                })
				this.ifload = false;
			},
            //保存数据
            saveData() {
                this.ifload = true;
                this.form.commodity_category = this.commodity_category;
                this.$post_('trade/commodity/set-day-income',this.form,(res) =>{
                    console.log(res);
                    this.ifload = false;
                    if(res.code=='0'){
                        this.$message.success(res.msg);
                        // this.$router.back(-1);
                    }else{
                        this.$message.error(res.msg);
                    }
                })
            },
            handleClick(tab, event){
                this.commodity_category = tab.name;
                this.$nextTick(()=>{
                	this.getData();
                })
            },
		}
	}
</script>

<style scoped="scoped">
</style>
